package meituan;

import java.util.Scanner;

/**
 * @author Hang
 * @date 2022/8/13
 * @project AutumnOffer
 * @description
 **/
public class Array {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] mf = new int[n];
        for(int i=0;i<n;i++){
            mf[i] = scanner.nextInt();
        }
        int count = 0;
        for(int i=0;i<n-2;i++){
            for(int j=1;j<n-1;j++){
                for(int k=2;k<n;k++){
                    if((i!=j&&i!=k&&j!=k)&&mf[i]-mf[j]==mf[j]*2-mf[k]){
                        count++;
                    }
                }
            }
        }
        System.out.println(count);
    }
}
